<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<#include "/common/resources.ftl"/>
<style>
	.red { 	background: #ef2b31;
		    width: 100px;
		    height: 40px;
		    line-height: 40px;
		    text-align: center;
		    color: #fff;
		    font-size: 16px;
		    border-radius: 5px;}
		    
	.shop_lis{ display:block;  overflow:hidden; margin-bottom:20px;}
	.shop_lis li{ width:23%; border:1px solid #c9c9c9; height:auto; overflow:hidden; float:left; margin-left:4px; margin-top:6px;}
	.shop_lis li p{ line-height:20px; margin-left:8px; color:#474747;}
	.shop_lis li span{ line-height:20px; margin-left:8px; color:#df5b5b;}
</style>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=99YtnXLTFuCDG65CCohePiwtaB6UKTAL"></script>
<script type="text/javascript">

	$(function(){
		$('#dd').window('close');
	});
	function m_submit(re){
		$("#remark_s").attr("value",$("#remark").val());
		$("#premisesStatus_id").attr("value",re);
		window.saveOrEditForm.submit();
	}
	
	
	function m_window(){
		$('#dd').window('open');
	
	}
	function m_back(){
		window.location.href = 'manage';
	}
	//地图所需变量
	//地图上得点
	var marker;
	//地图
	var map;
	//经纬度以及地址变量
	var lonel,latel,addrel;
	function initPosition(){
		var lon = $("*[name="+lonel+"]").val() || 116.400244;
		var lat = $("*[name="+latel+"]").val() || 39.92556;
		// 百度地图API功能
		if(!map){
			map = new BMap.Map("map");
		}else{
			map.clearOverlays();   
		}
		var point = new BMap.Point(lon,lat);
		map.centerAndZoom(point, 12);
		marker = new BMap.Marker(point);// 创建标注
		map.addOverlay(marker);             // 将标注添加到地图中
		marker.enableDragging();           // 不可拖拽
		$("#addDialog").panel("open");
	}
	function savePosition(){
		var p = marker.getPosition();       //获取marker的位置
		$("*[name="+lonel+"]").val(p.lng);
		$("*[name="+latel+"]").val(p.lat);
		$("#addDialog").panel("close");
	}
	
	//可守户型
	var id= '${model.id}';
	var apartmentlist = '${model.apartmentsList}';
	apartmentlist = apartmentlist?$.evalJSON(apartmentlist):[];
	function addApartment(){
		var area = $("#addForm").find('*[name="area"]').val();
		var apartmentLayout1 = $("#addForm").find('*[name="apartmentLayout1"]').val();
		var apartmentLayout2 = $("#addForm").find('*[name="apartmentLayout2"]').val();
		var apartmentLayout3 = $("#addForm").find('*[name="apartmentLayout3"]').val();
		var apartmentLayout4 = $("#addForm").find('*[name="apartmentLayout4"]').val();
		var url = $("#addForm").find('*[name="url2"]').val();
		var apartmentLayout = apartmentLayout1+apartmentLayout2+apartmentLayout3+apartmentLayout4;
		if(!$.trim(area)){
		 		$.messager.show({
						title:'YiXun助手',
						msg:'请输入面积！'
				});
				return false;
		}
		if(!$.trim(apartmentLayout)){
		 		$.messager.show({
						title:'YiXun助手',
						msg:'请选择户型！'
				});
				return false;
		}
		if(!$.trim(url)){
		 		$.messager.show({
						title:'YiXun助手',
						msg:'请上传图片！'
				});
				return false;
		}
		var apartment={
			id:'',
			premisesId:'',
			area:area,
			apartmentLayout:apartmentLayout,
			url:url
		}
		saveApartment(apartment);
	}
	//保存
	function saveApartment(apartment){
		if(id){
		}
		apartmentlist.push(apartment);
		$("#apartmentsList").val($.toJSON(apartmentlist));
		$("#addApartmentDialog").panel("close");
		renderApartment(apartment);
	}
	//渲染到页面
	function renderApartment(apartment){
		var html =   '<li id="'+apartment.id+'">'
		         +'<div><img src="'+apartment.url+'" width="100px" height="100px" alt=""></div>'
		         +'<p>'+apartment.apartmentLayout+'  '+apartment.area+'平</p>'
		         +'<span class="del">删除</span>'
		         +'<input type="hidden" name="apartments" value='+$.toJSON([apartment])+' class="ipt_226" />'
		         +'</li>'
		$(".shop_lis").append(html);
	}
	//渲染到页面
	function delApartment(index){
		var apartment = apartmentlist[index];
		if(apartment.id){
			//删除
				$.messager.confirm('确认!','你确定要删除此户型吗?',function(res){
					if(res){
						$.post("${ctx}/xf/apartmentlayoutdiagram/del",{'id':apartment.id},function(result){
							if (result.errorMsg){
								$.messager.show({
									title: '友情提示',
									msg: 'result.errorMsg'
								});
								m_datagrid.datagrid('reload');
							} else {
								$.messager.show({
									title: '友情提示',
									msg: '删除成功'
								});
								apartmentlist.splice(index,1);
								$(".shop_lis").find('li').eq(index).remove();
								$("#apartmentsList").val($.toJSON(apartmentlist));
							}
						},'json');
					}
			 });
		}else{
			apartmentlist.splice(index,1);
			$(".shop_lis").find('li').eq(index).remove();
			$("#apartmentsList").val($.toJSON(apartmentlist));
			$.messager.show({
									title: '友情提示',
									msg: '删除成功'
			});
		}
	}
	$(function(){
		$(".modify_property").on("click",function(){
			lonel=$(this).attr("lon");
			latel=$(this).attr("lat");
			addrel=$(this).attr("addr");
			initPosition();
		})
		$(".add_apartment").on("click",function(){
			$("#addForm").form("clear");
			$("#addForm").find("img").hide();
			$("#addApartmentDialog").panel("open");
		})
		$(".shop_lis").on("click","li .del",function(){
			var index = $(this).parent("li").index();
			delApartment(index);
		})
		
		for(var apartment in apartmentlist){
			renderApartment(apartmentlist[apartment]);
		}
	})
	
	
	<#if errorMsg?exists >alert('${errorMsg}');</#if>
</script>
</head>
<body style="height:3000px;">
	<form action="${ctx}/xf/premises/audit" method="post" class="loan_list_form" name="saveOrEditForm">
  	<input type="hidden" name="id" value="<#if model?exists >${model.id}</#if>" />
  	<input type="hidden" id="premisesStatus_id" name="premisesStatus" style="height:39px;width:266px;" />
  	<input type="hidden" name="remark" id="remark_s">
  	<div class="fm_sty" style="margin: 20px 0px 0px;">
		<div class="ipt_line">
			<span class="ipt_title" style="margin-bottom:10px;font-size: 20px;">基本信息</span>
			<hr/>
		</div>
       	<div class="ipt_line">
			<span class="ipt_title">城市</span>
			<#if model?exists >${model.area.fullName}</#if>
		</div>
       	<div class="ipt_line">
			<span class="ipt_title">楼盘名称</span>
			<input type="hidden" name="id"value="<#if model?exists >${model.id}</#if>">
			<#if model?exists >${model.name}</#if>
		</div>
       	<div class="ipt_line">
			<span class="ipt_title">楼盘标签</span>
			<#if model?exists >${model.codeName}</#if>
		</div>
       	<div class="ipt_line">
			<span class="ipt_title">结佣方式</span>
			<#if model?exists >${model.commissionWay}</#if>
		</div>
       	<div class="ipt_line">
			<span class="ipt_title">物业类型</span>
			<#if model?exists >${model.estateType}</#if>
		</div>
       	<div class="ipt_line">
			<span class="ipt_title">建筑类别</span>
			<#if model?exists >${model.buildingType}</#if>
		</div>
       	<div class="ipt_line">
			<span class="ipt_title">装修状况</span>
			<#if model?exists >${model.decorationType}</#if>
		</div>
       	<div class="ipt_line">
			<span class="ipt_title">容积率</span>
			<#if model?exists >${model.plotRatio}</#if>%
		</div>
       	<div class="ipt_line">
			<span class="ipt_title">绿化率</span>
			<#if model?exists >${model.greeningRate}</#if>%
		</div>
		<div class="ipt_line">
			<span class="ipt_title">在售状态</span>
			<#if model?exists >${model.saleStatus}</#if>
		</div>
		<div class="ipt_line">
			<span class="ipt_title">开盘时间</span>
			<#if model?exists >${model.openingTime?string("yyyy-MM-dd")}</#if>
		</div>
       	<div class="ipt_line">
			<span class="ipt_title">入住时间</span>
			<#if model?exists >${model.checkInTime?string("yyyy-MM-dd")}</#if>
		</div>
		<div class="ipt_line">
			<span class="ipt_title">开发商</span>
			<#if model?exists >${model.buildingCompany}</#if>
		</div>
		<div class="ipt_line">
			<span class="ipt_title">物业费</span>
			<#if model?exists >${model.propertyCharges}</#if>
		</div>
       	<div class="ipt_line">
			<span class="ipt_title">物业公司</span>
			<#if model?exists >${model.propertyCompany}</#if>
		</div>
       	<div class="ipt_line">
			<span class="ipt_title">产权年限</span>
			<#if model?exists >${model.rightYears}</#if>年
		</div>
       	<div class="ipt_line">
			<span class="ipt_title">均价</span>
			<#if model?exists >${model.averagePrice}</#if>
		</div>
		<div class="ipt_line">
			<span class="ipt_title">物业地址</span>
			<#if model?exists >${model.propertyAddr}</#if>
		</div>
		<div class="ipt_line">
			<span class="ipt_title">售楼部地址</span>
			<#if model?exists >${model.saleAddr}</#if>
		</div>
			
		<div class="ipt_line">
			<span class="ipt_title" style="margin-bottom:10px;font-size: 20px;">分销信息</span>
			<hr/>
		</div>
		<div class="ipt_line">
			<span class="ipt_title">促销信息</span>
			<#if model?exists >${model.discount}</#if>
		</div>
		<div class="ipt_line">
			<span class="ipt_title">成交佣金</span>
			<#if model?? && model.commission != null && model.commission!=''>${model.commission}&emsp;元
			<#else>
				<#if model?? && model.commissionRate!=null && model.commissionRate!=''>${model.commissionRate}&emsp;%
				<#else>&emsp;元
				</#if>
			</#if>
		</div>
		<div class="ipt_line">
			<span class="ipt_title"><#if model.dealType == "2">现金奖<#else> 成交奖</#if></span>
			<#if model?exists >${model.dealAward}&emsp;元</#if>
		</div>
       	<div class="ipt_line">
			<span class="ipt_title">带看奖励</span>
			<#if model?exists >${model.reward}&emsp;元</#if>
		</div>
		<div class="ipt_line">
			<span class="ipt_title">报备保护时间</span>
			<#if model?exists >${model.visitProtect}&emsp;分钟</#if>
		</div>
		<div class="ipt_line">
			<span class="ipt_title">最短报备时间</span>
			<#if model?exists >${model.specialTime}&emsp;分钟</#if>
		</div>
		<div class="ipt_line">
			<span class="ipt_title">带看保护时间</span>
			<#if model?exists >${model.saveDays}&emsp;天</#if>
			<font color="red">《报备已到访,过了设置的天数未认筹、认购、签约,报备自动转为无效,不填默认为7天》</font>
		</div>
		<div class="ipt_line">
			<span class="ipt_title">项目经理</span>
			<#if model?exists >${model.manager}</#if>
		</div>
       	<div class="ipt_line">
			<span class="ipt_title">联系方式</span>
			<#if model?exists >${model.mobile}</#if>
		</div>
		<div class="ipt_line">
			<span class="ipt_title">项目特色</span>
			<#if model?exists >${model.feature}</#if>
		</div>
		<div class="ipt_line">
			<span class="ipt_title">合作有效期</span>
			<#if model?exists >${model.cooperationBeginTime?string("yyyy-MM-dd")}</#if>-
			<#if model?exists >${model.cooperationEndTime?string("yyyy-MM-dd")}</#if>
		</div>
		<div class="ipt_line">
			<span class="ipt_title">合作规则</span>
			<#if model?exists >${model.cooperationRule}</#if>
		</div>

		<div class="ipt_line">
			<span class="ipt_title" style="margin-bottom:10px;font-size: 20px;">其他信息</span>
			<hr/>
		</div>			
		<div class="ipt_line">
			<span class="ipt_title">楼盘卖点</span>
			<#if model?exists >${model.selling}</#if>
		</div>
       	<div class="ipt_line">
			<span class="ipt_title">目标客户</span>
			<#if model?exists >${model.customer}</#if>
		</div>
       	<div class="ipt_line">
			<span class="ipt_title">拓客技巧</span>
			<#if model?exists >${model.saleSkill}</#if>
		</div>
		<div class="ipt_line">
			<span class="ipt_title">项目简介</span>
			<#if model?exists >${model.introduction}</#if>
		</div>
		<div class="ipt_line">
			<span class="ipt_title">楼书附件</span>
			<#if model.lsUrl?if_exists >
				<a href="${model.lsUrl!''}" target="_blank">
				<#if model.lsName?if_exists>
               	${model.lsName}
                <#else>
                                    查看
                </#if>
			</a>
			</#if>
		</div>
		<div class="ipt_line">
			<span class="ipt_title">可售户型</span>
			<p>
			<#list diagramList as diagram>
			  <img showbig src="${diagram.url}" width="50px;" height="50px;">
			</#list>
			</p>
		</div>
		<div class="ipt_line">
			<span class="ipt_title">封面图片</span>
			<p><img showbig src="${model.url}" width="100px;" height="100px;"></p>
		</div>
		<div class="ipt_line">
			<span class="ipt_title">全景看房</span>
			<#if model.panoramicView?if_exists>
			<p><a href="${model.panoramicView}" target="_blank">请点击看房链接</a></p>
			</#if>
		</div>
		<div id="dd" class="easyui-dialog" title="备注" style="width:400px;height:200px;"  data-options="iconCls:'icon-save',resizable:true,modal:true" >   
	     	<textarea style="width:380px;height:130px;" id="remark"></textarea>
   		 	<div region="south" border="false" style="text-align:right;height:30px;line-height:30px;">
				<a href="#" class="easyui-linkbutton" iconCls="icon-ok" plain="true" onclick="m_submit(2);">保存</a>
				<a href="#" class="easyui-linkbutton" iconCls="icon-cancel" plain="true" onclick="javascript:$('#dd').window('close')">取消</a>
		 	</div>
		</div>  

		<div class="ipt_line_long">
  		<#if model.premisesStatus=="0" >
        <#--<button class="red_100" onclick="javascript:m_submit(1);">审核通过</button>
        	<input type="button" value="审核不通过" class="red_100" onclick="javascript:m_window();">-->
        	<input type="button" value="待审核" class="red_100" style="background-color:gray" onclick="javascript:#">
      	</#if>
         	<button class="red_100" onclick="javascript:m_back();return false;" style="background-color:#74D86A">返回</button>
		</div>
	</div>
	</form> 
	
</body>
</html>
